
import {
    Object3D, Mesh,Color,
    SphereGeometry, BoxBufferGeometry,
    // CylinderBufferGeometry, PlaneGeometry,
    MeshStandardMaterial, MeshLambertMaterial, PlaneBufferGeometry,
} from "three";

import { picTexture } from './TTexture'

export const basicObjectList: Object3D[] = []

const ground: Mesh = new Mesh(
    new BoxBufferGeometry(200, 10, 200),
    new MeshStandardMaterial({ color: 0x0ffff0, roughness: 0 })
);
ground.position.y += -5
ground.receiveShadow = true;

const box: Mesh = new Mesh(
    new BoxBufferGeometry(5, 5, 5),
    new MeshStandardMaterial({ color: 'red', metalness: 0.8, roughness: 0.2 })
);
box.position.set(-5, 2.5, 0);
box.castShadow = true;

//添加模型 球体
export const ball: Mesh = new Mesh(
    new SphereGeometry(2, 32, 32),
    new MeshLambertMaterial({ color: 'green', })
);
ball.position.x += 5;
ball.position.y += 2;
ball.castShadow = true;

ball.updateMatrix();
ball.updateMatrixWorld();

let ballmatcolor = (ball.material as MeshStandardMaterial).color;
ball.addEventListener('mouseenter',()=>{
    console.log('ball mouseenter');
    (ball.material as MeshStandardMaterial).color = new Color('blue');
})
ball.addEventListener('mouseleave',()=>{
    console.log('ball mouseleave');
    (ball.material as MeshStandardMaterial).color = ballmatcolor;
})
ball.addEventListener('mousemove',()=>{
    console.log('ball mousemove');
})

//
const plane: Mesh = new Mesh(
    new PlaneBufferGeometry(50, 50),
    new MeshStandardMaterial({
        map: picTexture, 
    })
);
plane.position.z += -10;
plane.position.y += 25;
plane.castShadow = true;

// const cylinder: Mesh = new Mesh(
//     new CylinderBufferGeometry(),
//     new MeshStandardMaterial({ color: 0x0ffff0 })
// );
// cylinder.position.set(5, -5, -5);


basicObjectList.push(ground, box, ball, plane);